<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outer{
            width: 500px;
            height: 500px;
            border-bottom: 10px solid black;
            overflow: hidden;
        }
        .show{
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: blueviolet;
            /*设置动画的效果*/
            animation: ball 2s infinite ease-in ;
        }
      /*设置关键帧*/
      @keyframes ball {
          from{
              margin-top: 0px;
              animation-timing-function: ease-in;
              
          }
          /*动画过程到了25%的时候设置效果*/
        50%{
           margin-top: 400px;
           animation-timing-function: ease-in-out;
         }
        
      60%{
          margin-top: 200px;
          animation-timing-function: ease-in;

      }
  70%{
    margin-top: 400px;
           animation-timing-function: ease-in-out;
  }
     
80%{
    margin-top: 300px;
    animation-timing-function: ease-in;
}
90%{
    margin-top: 399px;
}
        to {
           margin-top: 400px;
          
         }
      }


   
    </style>
</head>
<body>
    <div class="outer">
 <div class="inner">

 </div>
    </div>
</body>
<form action="#">
    <button class="btn">点击开始游戏</button>
</form>
<script>
    let btn= document.querySelector(".btn");
    let isclick=false;
    let  innerdiv=document.querySelector(".inner");

    btn.addEventListener("click",()=>{
       if(!isclick){
        event.target.innerHTML="点击开始游戏";
        isclick=true;
         innerdiv.classList.add("show");
       }
       else{
        event.target.innerHTML="点击结束游戏";
        isclick=false;
         innerdiv.classList.toggle("show");
       }
    })


</script>
</html>